/**
 * File Name	: DataField.h
 * Location		: /Data/
 * Lib.Name		: Data.a
 * Designer		: OS (12-09-06)
 */

#pragma once

#include "../Core/RawData.h"
#include "../jsoncpp/json/value.h"

typedef unsigned int ubit;
typedef signed int sbit;
typedef sbit bit;

namespace Core
{
	/**
	 * Kelas Data Field, bapak semua kelas entitas
	 */
	class DataField
	{
	private:
		bool m_Set;
		
	protected:
		//for Asman
		std::string m_Name;
		unsigned char m_NumberOfItems;

	public:

		DataField();

		/**
		 * Destruktor Data Field
		 */
		virtual ~DataField();

		virtual void Init() {};

		/**
		 * Me reset state dari Data Field menjadi state semula
		 */
		virtual void Reset() = 0;

		/**
		 * Mengartikan Raw Data menjadi kelas entitas
		 * @param p_Data Raw Data yang akan diartikan
		 */
		virtual void ReadRawData(Core::RawData& p_Data) = 0;

		/**
		 * Menuliskan entitas ke Raw Data
		 * @param p_Data Raw Data tempat entitas akan menuliskan
		 */
		virtual void WriteRawData(Core::RawData& p_Data) = 0;
		
		virtual void ReadJSON(Json::Value& pValue) {}
		
		virtual void WriteJSON(Json::Value& pValue) {}

		virtual void SynchronizeFrom(DataField& p_DataField);

		void Set();
		void Unset();
		bool Isset();

		//For Asman!
		virtual std::string GetName();
		virtual void SetName(std::string p_Name);
		virtual unsigned char GetNumberOfItems();
		virtual std::string GetItemByIndex(unsigned char p_Index);
		virtual void SetItemByIndex(unsigned char p_Index, std::string p_String);
	};

}
